home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / filutil / mdf130.zip / MDFL130.ZIP / CPPSAMP.ZIP / SAMPLE.CPP < prev   
C/C++ Source or Header  |  1995-01-12  |  2KB  |  104 lines

  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5.  
  6. #include "mpatch.h"
  7.  
  8.  
  9.  
  10. class MyPatch : public MPatch
  11.     {
  12.     public:
  13.      void Show_start();
  14.      void Show();
  15.      void Show_end();
  16.     };
  17.  
  18.  
  19. void MyPatch::Show_start()
  20. {
  21.  puts("\nStart applying patch. Please Wait...");
  22. }
  23.  
  24. void MyPatch::Show()
  25. {
  26.  static short i=0;
  27.  printf("%3d",i++);
  28. }
  29.  
  30. void MyPatch::Show_end()
  31. {
  32.  puts("\nOk. Finished!");
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39. int main(int argc, char *argv[])
  40. {
  41.  MyPatch patch;
  42.  
  43.  puts("SAMPLE - A simply *.MDF applier");
  44.  puts("(C) 1993/94 Maurizio Giunti");
  45.  
  46.  char diffile[256];
  47.  char oldfile[256];
  48.  char newfile[256];
  49.  
  50.  if((argc<2)||(argc>4))
  51.     {
  52.      puts("Usage: SAMPLE <mdf> [<old>] [<new>]");
  53.      return 0;
  54.     }
  55.  
  56.  *diffile='\0';
  57.  *oldfile='\0';
  58.  *newfile='\0';
  59.  
  60.  for(short i=1;i<argc;i++)
  61.     {
  62.      if(*diffile=='\0') strcpy(diffile,argv[i]);
  63.      else if(*oldfile=='\0') strcpy(oldfile,argv[i]);
  64.      else strcpy(newfile,argv[i]);
  65.     }
  66.  
  67.  
  68.  // Getting info from MDF file
  69.  MDF_header_info hi;
  70.  
  71.  i=readMDFhead(diffile,&hi);
  72.  switch(i)
  73.     {
  74.      case 0:
  75.      puts("MDF file not found !");
  76.      return 0;
  77.  
  78.      case -1:
  79.      puts("Not an MDF file !");
  80.      return 0;
  81.  
  82.      case -2:
  83.      puts("Wrong MDF version !");
  84.      return 0;
  85.     }
  86.  printf("Algorithm version: %s\n",hi.alg_ver);
  87.  printf("MDF file produced by: %s\n",hi.registeredto);
  88.  printf("Chunk len: %d  Number of chunks: %lu\n",hi.chunk_len,hi.n_chunks);
  89.  
  90.  
  91.  // Start applying patch
  92.  patch.SetRate(3);
  93.  if(patch.MDFPatch(diffile,oldfile,newfile)!=0)
  94.     {
  95.      puts(patch.LastError());
  96.     }
  97.  else puts("<Done!>");
  98.  return 0;
  99. }
  100.  
  101.  
  102.  
  103.  
  104.